/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Dotke
 */
@Entity
@Table(name = "ACCOUNTTRANSACTION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Accounttransaction.findAll", query = "SELECT a FROM Accounttransaction a"),
    @NamedQuery(name = "Accounttransaction.findByTransId", query = "SELECT a FROM Accounttransaction a WHERE a.transId = :transId"),
    @NamedQuery(name = "Accounttransaction.findByTransType", query = "SELECT a FROM Accounttransaction a WHERE a.transType = :transType"),
    @NamedQuery(name = "Accounttransaction.findByTransDate", query = "SELECT a FROM Accounttransaction a WHERE a.transDate = :transDate"),
    @NamedQuery(name = "Accounttransaction.findByTransAmount", query = "SELECT a FROM Accounttransaction a WHERE a.transAmount = :transAmount"),
    @NamedQuery(name = "Accounttransaction.findByTransDescription", query = "SELECT a FROM Accounttransaction a WHERE a.transDescription = :transDescription")})
public class Accounttransaction implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "TRANS_ID")
    private Integer transId;
    @Basic(optional = false)
    @Column(name = "TRANS_TYPE")
    private char transType;
    @Basic(optional = false)
    @Column(name = "TRANS_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date transDate;
    @Basic(optional = false)
    @Column(name = "TRANS_AMOUNT")
    private int transAmount;
    @Basic(optional = false)
    @Column(name = "TRANS_DESCRIPTION")
    private String transDescription;
    @JoinColumn(name = "TRANS_FROM_ACCOUNT", referencedColumnName = "ACCOUNT_ID")
    @ManyToOne
    private Account transFromAccount;
    @JoinColumn(name = "TRANS_TO_ACCOUNT", referencedColumnName = "ACCOUNT_ID")
    @ManyToOne
    private Account transToAccount;

    public Accounttransaction() {
    }

    public Accounttransaction(Integer transId) {
        this.transId = transId;
    }

    public Accounttransaction(Integer transId, char transType, Date transDate, int transAmount, String transDescription) {
        this.transId = transId;
        this.transType = transType;
        this.transDate = transDate;
        this.transAmount = transAmount;
        this.transDescription = transDescription;
    }

    public Integer getTransId() {
        return transId;
    }

    public void setTransId(Integer transId) {
        this.transId = transId;
    }

    public char getTransType() {
        return transType;
    }

    public void setTransType(char transType) {
        this.transType = transType;
    }

    public Date getTransDate() {
        return transDate;
    }

    public void setTransDate(Date transDate) {
        this.transDate = transDate;
    }

    public int getTransAmount() {
        return transAmount;
    }

    public void setTransAmount(int transAmount) {
        this.transAmount = transAmount;
    }

    public String getTransDescription() {
        return transDescription;
    }

    public void setTransDescription(String transDescription) {
        this.transDescription = transDescription;
    }

    public Account getTransFromAccount() {
        return transFromAccount;
    }

    public void setTransFromAccount(Account transFromAccount) {
        this.transFromAccount = transFromAccount;
    }

    public Account getTransToAccount() {
        return transToAccount;
    }

    public void setTransToAccount(Account transToAccount) {
        this.transToAccount = transToAccount;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (transId != null ? transId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accounttransaction)) {
            return false;
        }
        Accounttransaction other = (Accounttransaction) object;
        if ((this.transId == null && other.transId != null) || (this.transId != null && !this.transId.equals(other.transId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.entity.Accounttransaction[ transId=" + transId + " ]";
    }
    
}
